package ar.com.photo_admin.domain

import ar.com.photo_admin.domain.order_state.*;

abstract class PurchaseOrderState {
	
	PurchaseOrder order
	
	static belongsTo = [PurchaseOrder]
	
	def confirm(){
		this.order.state = new ConfirmedOrderState(order);		
	}
	
	def approve(){
		this.order.state = new ApprovedOrderState(order);
	}
	
	def cancel(){
		this.order.state = new CancelledOrderState(order);
	}
	
	def finalizeOrder(){
		this.order.state = new FinalizedOrderState(order);
	}
	
	def dispute(){
		this.order.state = new InDisputeOrderState(order);
	}
	
	def inProcess(){
		this.order.state = new InProcessOrderState(order);
	}
	
	def pending(){
		this.order.state = new PendingOrderState(order);
	}	
	
	def refund(){
		this.order.state = new RefundedOrderState(order);
	}
	
	def reject(){
		this.order.state = new RejectedOrderState(order);
	}
	
	abstract def showDescription();
	
	abstract def isCancellable();
	
	abstract def isRefundable();
	
	abstract def isFinalizable();
	
	abstract def isRegistered();
	
    static constraints = {
		
    }
	
	static mapping = {
		tablePerHierarchy true
	}
}
